package cn.tom.tompicturebackend.config;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "cos.client")
@Data
public class CosClientConfig {
    /**
     * 域名
     */
    private String host;

    /**
     * secretId
     */
    private String secretId;

    /**
     * secretKey
     */
    private String secretKey;

    private String region;

    private String bucket;

    @Bean
    public COSClient cosClient(){
        //初始化用户信息
        COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
         //Configuration configuration = new Configuration(new Region(region));
        ClientConfig clientConfig = new ClientConfig(new com.qcloud.cos.region.Region(region));

        return new COSClient(cred, clientConfig);
    }



}
